package com.mcptt.http.auth.process.digest.result;

import com.mcptt.http.auth.process.result.AuthResult;
import com.mcptt.http.auth.process.result.info.AuthorizationInfo;

public class SecondGetResult extends AuthResult
{
    private AuthorizationInfo authInfo = null;

	private String url = null;

    public SecondGetResult(int result, String desc)
    {
	super(result, desc);
    }

    public String getErrStr()
    {
	StringBuffer strBuf = new StringBuffer("SecondGetResult  ");
	strBuf.append("result=").append(result);
	if(desc != null
		&& desc.length() >0)
	{
	    strBuf.append(",");
	    strBuf.append("desc=").append(desc);
	}
	else
	{
	    strBuf.append(";");
	}

	return strBuf.toString();
    }
    
    public String toString()
    {
  	StringBuffer strBuf = new StringBuffer("SecondGetResult  ");
  	strBuf.append("authInfo=").append(authInfo).append(";");

  	return strBuf.toString();
    }
    
    public boolean isSuc()
    {
	if (result == 401)
	{
	    return true;
	}
	return false;
    }
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUrl() {
		return url;
	}
    public boolean checkReturnParamOk()
    {
	if(authInfo == null
		|| !authInfo.checkReturnParamOk())
	{
	    return false;
	}
	return true;
    }

    public String getAuthInfoDscp()
    {
	return authInfo.getDscpStr();
    }

    public void generateDigestAuth(String username, String password,String uri)
    {
	if(authInfo != null)
	{
	    authInfo.generateDigestAuth(username, password,uri);
	}
    }

    public void setAuthInfo(String authStr)
    {
	this.authInfo = new AuthorizationInfo(authStr);
    }
}
